package com.cdzy.service.impl;

import com.cdzy.pojo.Notice;
import com.cdzy.mapper.NoticeMapper;
import com.cdzy.service.NoticeService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 通知表(Notice)表服务实现类
 *
 * @author makejava
 * @since 2025-04-01 10:04:22
 */
@Service("noticeService")
public class NoticeServiceImpl implements NoticeService {

    @Resource
    private NoticeMapper noticeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param noticeId 主键
     * @return 实例对象
     */
    @Override
    public Notice queryById(Integer noticeId) {
        return this.noticeMapper.queryById(noticeId);
    }


    /**
     * 新增数据
     *
     * @param notice 实例对象
     * @return 实例对象
     */
    @Override
    public Notice insert(Notice notice) {
        this.noticeMapper.insert(notice);
        return notice;
    }

    /**
     * 修改数据
     *
     * @param notice 实例对象
     * @return 实例对象
     */
    @Override
    public Notice update(Notice notice) {
        this.noticeMapper.update(notice);
        return this.queryById(notice.getNoticeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param noticeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer noticeId) {
        return this.noticeMapper.deleteById(noticeId) > 0;
    }

    @Override
    public List<Notice> getNoticeList() {
        List<Notice> noticeList = noticeMapper.getNoticeList();
        return noticeList;
    }
}
